import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Patch,
  Post,
} from '@nestjs/common';
import { FilmFileRelationalService } from './film_file_relational.service';
import { UpdateFilmFileRelationalDto } from './dto/update-film_file_relational.dto';
import { CreateFilmFileRelationalDto } from './dto/create-film_file_relational.dto';

@Controller('film-file-relational')
export class FilmFileRelationalController {
  constructor(
    private readonly filmFileRelationalService: FilmFileRelationalService,
  ) {}

  @Post('createRelation')
  createRelation(
    @Body() createFilmFileRelationalDto: CreateFilmFileRelationalDto,
  ) {
    return this.filmFileRelationalService.create(createFilmFileRelationalDto);
  }

  @Get('getAllRelation')
  getAllRelation() {
    return this.filmFileRelationalService.findAll();
  }

  @Get('getRelationById/:id')
  findOne(@Param('id') id: string) {
    return this.filmFileRelationalService.findOne(id);
  }

  @Get('getFileTypeByFilmId/:filmId/:fileType')
  getFileTypeByFilmId(
    @Param('filmId') film_id: string,
    @Param('fileType') file_type: string,
  ) {
    return this.filmFileRelationalService.getFileTypeByFilmId(
      film_id,
      file_type,
    );
  }

  @Patch('updateFilmToFileRelationItem/:id')
  updateFilmToFileRelationItem(
    @Param('id') id: string,
    @Body() updateFilmFileRelationalDto: UpdateFilmFileRelationalDto,
  ) {
    return this.filmFileRelationalService.updateFilmToFileRelationItem(
      id,
      updateFilmFileRelationalDto,
    );
  }

  @Delete('deleteRelationalById/:id')
  remove(@Param('id') id: string) {
    return this.filmFileRelationalService.remove(id);
  }

  @Delete('removeRelationByFileId/:fileId')
  removeRelationByFileId(@Param('fileId') fileId: string) {
    return this.filmFileRelationalService.removeRelationByFileId(fileId);
  }

  @Post('getFilesIsUsedByFilm')
  getFilesIsUsedByFilm(@Body() param) {
    return this.filmFileRelationalService.getFilesIsUsedByFilm(param);
  }

  @Post('updateFilmToFileRelationItemByFileIdFilmId')
  updateFilmToFileRelationItemByFileIdFilmId(
    @Body() updateFilmFileRelationalDto: UpdateFilmFileRelationalDto,
  ) {
    return this.filmFileRelationalService.updateFilmToFileRelationItemByFileIdFilmId(
      updateFilmFileRelationalDto,
    );
  }

  @Post('getFilmToFileRelationItemByFileIdFilmId')
  getFilmToFileRelationItemByFileIdFilmId(@Body() param) {
    return this.filmFileRelationalService.getFilmToFileRelationItemByFileIdFilmId(
      param,
    );
  }

  @Get('getIsUsedByFileId/:fileuuid')
  getIsUsedByFileId(@Param('fileuuid') fileuuid: string) {
    return this.filmFileRelationalService.getIsUsedByFileId(fileuuid);
  }
}
